from ui_auto2.public.pages.basepage import BasePage
from ui_auto2.data.input_elem import Bbselem_Iput
from selenium.webdriver.common.action_chains import ActionChains
import unittest
from time import sleep
from ui_auto2.public.utils.read_ini import Read_ini
import os
from  ui_auto2.config.config import *
file=os.path.join(data_path,"data.ini")
r=Read_ini(file)
framename=r.read_ini_data("testbbs_data","id")
title=r.read_ini_data("testbbs_data","value")
conten=r.read_ini_data("testbbs_data","value1")


class Test_Post_Arc(BasePage):
    def test_postarc(self):
        elem1=BasePage.search_elem(Bbselem_Iput.bbs_my)
        BasePage.move_to_element(elem1)
        elem2=BasePage.search_elem(Bbselem_Iput.bbs_tiezi)
        BasePage.click(elem2)
        elem3=BasePage.search_elem(Bbselem_Iput.bbs_post_btn)
        BasePage.click(elem3)
        sleep(1)
        elem4=BasePage.search_elem(Bbselem_Iput.bbs_Discuz)
        BasePage.click(elem4)
        elem5=BasePage.search_elem(Bbselem_Iput.bbs_MRmokuai)
        BasePage.click(elem5)
        self.elem = BasePage.search_elem(Bbselem_Iput.bbs_new_post)
        elem6= self.elem
        BasePage.click(elem6)
        elem7=BasePage.search_elem(Bbselem_Iput.bbs_title)
        BasePage.sendkeys(elem7,title)
        BasePage.switch_frame(framename)
        elem8=BasePage.search_elem(Bbselem_Iput.bbs_iframe)
        BasePage.sendkeys(elem8,conten)
        BasePage.quiet_frame()
        elem9=BasePage.search_elem(Bbselem_Iput.bbs_post)
        BasePage.click(elem9)
        try:
            elem10=BasePage.search_elem(Bbselem_Iput.bbs_huifu)
            value=BasePage.text(elem10)
            self.assertEqual(elem10,"回复")
        except Exception as e:
            print(e)

if __name__ == '__main__':
    unittest.main()




